package com.bdq.basic.application.service.impl;

import cn.hutool.core.convert.Convert;
import com.bdq.basic.application.model.dto.CategoryGetAppDTO;
import com.bdq.basic.application.model.dto.RegionGetAppDTO;
import com.bdq.basic.application.model.query.CategoryGetQry;
import com.bdq.basic.application.model.query.RegionGetQry;
import com.bdq.basic.application.service.BaseAppQueryService;
import com.bdq.basic.domain.model.dto.CategoryGetDomainDTO;
import com.bdq.basic.domain.model.dto.RegionGetDomainDTO;
import com.bdq.basic.domain.model.dto.req.CategoryGetReqDTO;
import com.bdq.basic.domain.model.dto.req.RegionGetReqDTO;
import com.bdq.basic.domain.service.BaseDomainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author malei
 * @date 2024-05-02 17:19
 */
@Service
public class BaseAppQueryServiceImpl implements BaseAppQueryService {

    @Resource
    private BaseDomainService baseDomainService;

    @Override
    public List<CategoryGetAppDTO> getCategory(CategoryGetQry qry) {
        // 1 获取分类
        List<CategoryGetDomainDTO> dtoList = baseDomainService.getCategory(Convert.convert(CategoryGetReqDTO.class, qry));
        return Convert.toList(CategoryGetAppDTO.class, dtoList);
    }

    @Override
    public RegionGetAppDTO getRegion(RegionGetQry qry) {
        // 1 获取区域
        RegionGetDomainDTO domainDTO = baseDomainService.getRegion(Convert.convert(RegionGetReqDTO.class, qry));
        return Convert.convert(RegionGetAppDTO.class, domainDTO);
    }
}
